<!DOCTYPE html>
<html lang="zh-CN" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>交易引擎 | Homalos</title>
    <meta name="description" content="基于 Python 的量化交易系统">
    <meta name="generator" content="VitePress v1.6.3">
    <link rel="preload stylesheet" href="/assets/style.RmNjDeKb.css" as="style">
    <link rel="preload stylesheet" href="/vp-icons.css" as="style">
    <script type="module" src="/assets/chunks/metadata.28daeedd.js"></script>
    <script type="module" src="/assets/app.BvKZi2Jp.js"></script>
    <link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
    <link rel="modulepreload" href="/assets/chunks/framework.CXkkaYWf.js">
    <link rel="modulepreload" href="/assets/chunks/theme.C_3djJbO.js">
    <link rel="modulepreload" href="/assets/chunks/katex.ChWnQ-fc.js">
    <link rel="modulepreload" href="/assets/chunks/dagre-FFZHY6LT.v5YVXi2p.js">
    <link rel="modulepreload" href="/assets/chunks/c4Diagram-6F6E4RAY.nCOphmw6.js">
    <link rel="modulepreload" href="/assets/chunks/flowDiagram-PKI6S5ZS.CNud1oVM.js">
    <link rel="modulepreload" href="/assets/chunks/erDiagram-R3QVA2FD.DXgbj8um.js">
    <link rel="modulepreload" href="/assets/chunks/gitGraphDiagram-GW3U2K7C.BIFeTK-V.js">
    <link rel="modulepreload" href="/assets/chunks/ganttDiagram-EK5VF46D.DQ3Wppe5.js">
    <link rel="modulepreload" href="/assets/chunks/infoDiagram-XT3IWWJI.BaVwhgm7.js">
    <link rel="modulepreload" href="/assets/chunks/pieDiagram-NIOCPIFQ.DSbeskqj.js">
    <link rel="modulepreload" href="/assets/chunks/quadrantDiagram-2OG54O6I.DF4IDJMG.js">
    <link rel="modulepreload" href="/assets/chunks/xychartDiagram-H2YORKM3.CdWfFttn.js">
    <link rel="modulepreload" href="/assets/chunks/requirementDiagram-SO3GGRV7.DMU_G9xQ.js">
    <link rel="modulepreload" href="/assets/chunks/sequenceDiagram-ZIKVLSP4.kn4OakjH.js">
    <link rel="modulepreload" href="/assets/chunks/classDiagram-BGRH5UQR.DgQjJs6U.js">
    <link rel="modulepreload" href="/assets/chunks/classDiagram-v2-O24JOBDK.DgQjJs6U.js">
    <link rel="modulepreload" href="/assets/chunks/stateDiagram-XX37X6EN.CRy2e-oJ.js">
    <link rel="modulepreload" href="/assets/chunks/stateDiagram-v2-GD6S3NHB.BvRhId1O.js">
    <link rel="modulepreload" href="/assets/chunks/journeyDiagram-EWQZEKCU.BmQuVtJT.js">
    <link rel="modulepreload" href="/assets/chunks/timeline-definition-RI47OAVP.BxnQlAvf.js">
    <link rel="modulepreload" href="/assets/chunks/mindmap-definition-CZNETY7S.COCrfbvy.js">
    <link rel="modulepreload" href="/assets/chunks/kanban-definition-ILFWEQ3N.ChbXTd5M.js">
    <link rel="modulepreload" href="/assets/chunks/sankeyDiagram-4UZDY2LN.CpcNCvzD.js">
    <link rel="modulepreload" href="/assets/chunks/diagram-5UYTHUR4.J7RHmGCi.js">
    <link rel="modulepreload" href="/assets/chunks/diagram-ZTM2IBQH.BuJ-LU2f.js">
    <link rel="modulepreload" href="/assets/chunks/blockDiagram-PHRCVELO.DewF8s8X.js">
    <link rel="modulepreload" href="/assets/chunks/architectureDiagram-NQ2NVSRB.wzQlUmK0.js">
    <link rel="modulepreload" href="/assets/chunks/diagram-3EMPZRKU.1yGJgsvk.js">
    <link rel="modulepreload" href="/assets/chunks/virtual_mermaid-config.DDnGl6nM.js">
    <link rel="modulepreload" href="/assets/core_trading_engine.md.DFzq-XE4.lean.js">
    <link rel="icon" type="image/png" sizes="32x32" href="/assets/newnewlogo.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/assets/newnewlogo.png">
    <link rel="apple-touch-icon" sizes="180x180" href="/assets/newnewlogo.png">
    <link rel="mask-icon" href="/assets/newnewlogo.png" color="#5bbad5">
    <meta name="theme-color" content="#5f67ee">
    <script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
    <script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
  </head>
  <body>
    <div id="app"><div class="Layout" data-v-5d98c3a5><!--[--><!--[--><!--]--><!--]--><!--[--><span tabindex="-1" data-v-0b0ada53></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-0b0ada53>Skip to content</a><!--]--><!----><header class="VPNav" data-v-5d98c3a5 data-v-ae24b3ad><div class="VPNavBar" data-v-ae24b3ad data-v-6aa21345><div class="wrapper" data-v-6aa21345><div class="container" data-v-6aa21345><div class="title" data-v-6aa21345><div class="VPNavBarTitle has-sidebar" data-v-6aa21345 data-v-1168a8e4><a class="title" href="/" data-v-1168a8e4><!--[--><!--]--><!--[--><img class="VPImage logo" src="/assets/newnewlogo.png" width="24" height="24" alt data-v-8426fc1a><!--]--><span data-v-1168a8e4>Homalos</span><!--[--><!--]--></a></div></div><div class="content" data-v-6aa21345><div class="content-body" data-v-6aa21345><!--[--><!--]--><div class="VPNavBarSearch search" data-v-6aa21345><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-6aa21345 data-v-dc692963><span id="main-nav-aria-label" class="visually-hidden" data-v-dc692963> Main Navigation </span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/guide/quick_start" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>快速开始</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/other/about" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>关于</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-6aa21345 data-v-6c893767><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-6c893767 data-v-5337faa4 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-5337faa4></span><span class="vpi-moon moon" data-v-5337faa4></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-6aa21345 data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/Homalos/Homalos" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><span class="vpi-social-github"></span></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-6aa21345 data-v-bb2aa2f0 data-v-cf11d7a2><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-cf11d7a2><span class="vpi-more-horizontal icon" data-v-cf11d7a2></span></button><div class="menu" data-v-cf11d7a2><div class="VPMenu" data-v-cf11d7a2 data-v-b98bc113><!----><!--[--><!--[--><!----><div class="group" data-v-bb2aa2f0><div class="item appearance" data-v-bb2aa2f0><p class="label" data-v-bb2aa2f0>主题</p><div class="appearance-action" data-v-bb2aa2f0><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-bb2aa2f0 data-v-5337faa4 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-5337faa4></span><span class="vpi-moon moon" data-v-5337faa4></span><!--]--></span></span></button></div></div></div><div class="group" data-v-bb2aa2f0><div class="item social-links" data-v-bb2aa2f0><div class="VPSocialLinks social-links-list" data-v-bb2aa2f0 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/Homalos/Homalos" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><span class="vpi-social-github"></span></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--[--><!--[--><div class="VPFlyout VPNolebaseEnhancedReadabilitiesMenu VPNolebaseEnhancedReadabilitiesMenuFlyout" aria-label="阅读增强" role="menuitem" data-v-cf11d7a2><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-cf11d7a2><span class="text" data-v-cf11d7a2><span class="i-icon-park-outline:book-open option-icon" data-v-cf11d7a2></span><!----><span class="vpi-chevron-down text-icon" data-v-cf11d7a2></span></span></button><div class="menu" data-v-cf11d7a2><div class="VPMenu" data-v-cf11d7a2 data-v-b98bc113><!----><!--[--><!--]--></div></div></div><!--]--><!--]--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-6aa21345 data-v-e5dd9c1c><span class="container" data-v-e5dd9c1c><span class="top" data-v-e5dd9c1c></span><span class="middle" data-v-e5dd9c1c></span><span class="bottom" data-v-e5dd9c1c></span></span></button></div></div></div></div><div class="divider" data-v-6aa21345><div class="divider-line" data-v-6aa21345></div></div></div><!----></header><div class="VPLocalNav has-sidebar empty" data-v-5d98c3a5 data-v-a6f0e41e><div class="container" data-v-a6f0e41e><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-a6f0e41e><span class="vpi-align-left menu-icon" data-v-a6f0e41e></span><span class="menu-text" data-v-a6f0e41e>菜单</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-a6f0e41e data-v-8a42e2b4><button data-v-8a42e2b4>回到顶部</button><!----></div></div></div><aside class="VPSidebar" data-v-5d98c3a5 data-v-319d5ca6><div class="curtain" data-v-319d5ca6></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-319d5ca6><span class="visually-hidden" id="sidebar-aria-label" data-v-319d5ca6> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 collapsible collapsed" data-v-c40bc020 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h2 class="text" data-v-b3fd67f8>快速开始</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/quick_start" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>目录导航</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/homalos" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>什么是 Homalos</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/install" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>安装</p><!--]--></a><!----></div><!----></div><section class="VPSidebarItem level-1 collapsible" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h3 class="text" data-v-b3fd67f8>启动</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-2 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/start/start_data_center" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>启动数据中心</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/start/start_homalos" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>启动 Homalos</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h3 class="text" data-v-b3fd67f8>配置</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-2 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/config/system_config" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>系统全局配置</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/config/log_config" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>日志全局配置</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/config/data_center_config" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>数据中心配置</p><!--]--></a><!----></div><!----></div><!--]--></div></section><!--]--></div></section></div><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 collapsible collapsed has-active" data-v-c40bc020 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h2 class="text" data-v-b3fd67f8>核心架构</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/core/core" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>核心架构概述</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/core/event_driven_system" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>事件驱动系统</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/core/trading_engine" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>交易引擎</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/core/objects_and_service_registry" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>核心对象和服务注册表</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 collapsible collapsed" data-v-c40bc020 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h2 class="text" data-v-b3fd67f8>网关和外部连接</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/gateway/gateway" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>网关和外部连接概述</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/gateway/ctp_gateway" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>CTP网关</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/gateway/tts_gateway" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>TTS网关</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 collapsible collapsed" data-v-c40bc020 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h2 class="text" data-v-b3fd67f8>数据中心</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/datacenter/datacenter" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>数据中心概述</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 collapsible collapsed" data-v-c40bc020 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h2 class="text" data-v-b3fd67f8>数据服务</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/dataservice/dataservice" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>数据服务概述</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 collapsible collapsed" data-v-c40bc020 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h2 class="text" data-v-b3fd67f8>系统面板</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/dashboard/api" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>请求接口</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 collapsible collapsed" data-v-c40bc020 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h2 class="text" data-v-b3fd67f8>其它</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/other/community" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>社区资源</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/other/author" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>作者</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/other/about" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>联系</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-5d98c3a5 data-v-1428d186><div class="VPDoc has-sidebar has-aside" data-v-1428d186 data-v-39a288b8><!--[--><!--]--><div class="container" data-v-39a288b8><div class="aside" data-v-39a288b8><div class="aside-curtain" data-v-39a288b8></div><div class="aside-container" data-v-39a288b8><div class="aside-content" data-v-39a288b8><div class="VPDocAside" data-v-39a288b8 data-v-3f215769><!--[--><!--]--><!--[--><!--]--><nav aria-labelledby="doc-outline-aria-label" class="VPDocAsideOutline" data-v-3f215769 data-v-a5bbad30><div class="content" data-v-a5bbad30><div class="outline-marker" data-v-a5bbad30></div><div aria-level="2" class="outline-title" id="doc-outline-aria-label" role="heading" data-v-a5bbad30>页面导航</div><ul class="VPDocOutlineItem root" data-v-a5bbad30 data-v-b933a997><!--[--><!--]--></ul></div></nav><!--[--><!--]--><div class="spacer" data-v-3f215769></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-39a288b8><div class="content-container" data-v-39a288b8><!--[--><!--]--><main class="main" data-v-39a288b8><div style="position:relative;" class="vp-doc _core_trading_engine" data-v-39a288b8><div><h1 id="交易引擎" tabindex="-1">交易引擎 <a class="header-anchor" href="#交易引擎" aria-label="Permalink to &quot;交易引擎&quot;">​</a></h1><div my-4 class="vp-nolebase-page-properties vp-nolebase-page-properties-container"><div class="vp-nolebase-page-properties-grid grid grid-cols-[180px_auto] gap-1 &lt;sm:grid-cols-[120px_auto]"><!--[--><!--[--><div transition="all ease-in-out" flex items-start text="zinc-400 dark:zinc-500 sm &lt;sm:xs" duration-250><div transition="all ease-in-out" min-h="8 &lt;sm:7" px="2 &lt;sm:1" py="2 &lt;sm:1" w-full flex cursor-pointer items-center bg="hover:zinc-100 dark:hover:zinc-800" rounded-md duration-250><div i-icon-park-outline:add-text mr-1></div><span overflow-hidden text-ellipsis whitespace-nowrap>字数</span></div></div><div cursor-pointer transition="all ease-in-out" min-h="8 &lt;sm:7" px="2 &lt;sm:1" py="1.5 &lt;sm:1" flex="~ row wrap" items-center gap-1 rounded-md text="sm &lt;sm:xs" bg="hover:zinc-100 dark:hover:zinc-800" duration-250><div class="vp-nolebase-page-property" data-page-property="value" data-page-property-type="dynamic" data-page-property-dynamic-type="word-count" w-full inline-flex items-center><span>1085 字</span></div></div><!--]--><!--[--><div transition="all ease-in-out" flex items-start text="zinc-400 dark:zinc-500 sm &lt;sm:xs" duration-250><div transition="all ease-in-out" min-h="8 &lt;sm:7" px="2 &lt;sm:1" py="2 &lt;sm:1" w-full flex cursor-pointer items-center bg="hover:zinc-100 dark:hover:zinc-800" rounded-md duration-250><div i-icon-park-outline:timer mr-1></div><span overflow-hidden text-ellipsis whitespace-nowrap>阅读时间</span></div></div><div cursor-pointer transition="all ease-in-out" min-h="8 &lt;sm:7" px="2 &lt;sm:1" py="1.5 &lt;sm:1" flex="~ row wrap" items-center gap-1 rounded-md text="sm &lt;sm:xs" bg="hover:zinc-100 dark:hover:zinc-800" duration-250><div class="vp-nolebase-page-property" data-page-property="value" data-page-property-type="dynamic" data-page-property-dynamic-type="reading-time" w-full inline-flex items-center><span>5 分钟</span></div></div><!--]--><!--]--></div></div><p>交易引擎是 Homalos 量化交易系统的中央协调器，负责协调策略执行、风险管理、订单处理和账户管理。它采用事件驱动架构，能够实时处理市场数据和交易信号，同时保持严格的风险控制和订单生命周期管理。</p><p>底层事件系统详见<a class="VPNolebaseInlinePreviewLink" relative href="https://deepwiki.com/Homalos/Homalos/2.1-event-driven-system" target="_blank" rel="noreferrer" data-v-7fde401a><!--[-->事件驱动系统<!--]--><!----></a>，策略开发详见<a class="VPNolebaseInlinePreviewLink" relative href="https://deepwiki.com/Homalos/Homalos/5.1-strategy-development" target="_blank" rel="noreferrer" data-v-7fde401a><!--[-->策略开发<!--]--><!----></a>，网页端交易引擎管理详见<a class="VPNolebaseInlinePreviewLink" relative href="https://deepwiki.com/Homalos/Homalos/6.1-backend-api" target="_blank" rel="noreferrer" data-v-7fde401a><!--[-->后端API<!--]--><!----></a>。</p><h2 id="核心架构" tabindex="-1">核心架构 <a class="header-anchor" href="#核心架构" aria-label="Permalink to &quot;核心架构&quot;">​</a></h2><p>交易引擎由四个主要管理组件组成，它们协同处理交易操作的各个方面：</p><div class="language-text vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">text</span><pre class="shiki shiki-themes github-light github-dark vp-code" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0"><code><span class="line"><span>StrategyManager</span></span>
<span class="line"><span>RiskManager</span></span>
<span class="line"><span>OrderManager</span></span>
<span class="line"><span>AccountManager</span></span></code></pre></div><h2 id="策略管理" tabindex="-1">策略管理 <a class="header-anchor" href="#策略管理" aria-label="Permalink to &quot;策略管理&quot;">​</a></h2><p>该类<code>StrategyManager</code>处理交易策略的完整生命周期，从动态加载到执行监控和错误恢复。</p><h3 id="关键组件" tabindex="-1">关键组件 <a class="header-anchor" href="#关键组件" aria-label="Permalink to &quot;关键组件&quot;">​</a></h3><table tabindex="0"><thead><tr><th>成分</th><th>目的</th><th>关键方法</th></tr></thead><tbody><tr><td><code>StrategyManager</code></td><td>主要协调员</td><td><code>load_strategy()</code>，<code>start_strategy()</code>，<code>stop_strategy()</code></td></tr><tr><td><code>StrategyHealthMonitor</code></td><td>健康监测</td><td><code>check_strategy_health()</code>，<code>attempt_recovery()</code></td></tr><tr><td><code>StrategyEventHandler</code></td><td>事件处理</td><td>事件路由和处理</td></tr></tbody></table><h3 id="策略加载流程" tabindex="-1">策略加载流程 <a class="header-anchor" href="#策略加载流程" aria-label="Permalink to &quot;策略加载流程&quot;">​</a></h3><p>策略管理器使用动态模块加载在运行时实例化策略</p><p>该<code>load_strategy()</code>方法执行自动策略类发现和 UUID 生成：</p><ul><li>从文件路径动态导入策略模块</li><li>自动发现继承自<code>BaseStrategy</code></li><li>生成唯一的 UUID 用于策略识别</li><li>处理导入错误和验证失败</li></ul><h3 id="策略健康监测" tabindex="-1">策略健康监测 <a class="header-anchor" href="#策略健康监测" aria-label="Permalink to &quot;策略健康监测&quot;">​</a></h3><p>该系统包括具有自动恢复功能的全面健康监测：</p><p>恢复配置通过以下方式管理：</p><ul><li><code>auto_recovery_enabled</code>：切换自动恢复</li><li><code>max_recovery_attempts</code>：最大重试次数</li><li><code>recovery_attempts</code>：每个策略尝试的跟踪</li></ul><h2 id="风险管理器" tabindex="-1">风险管理器 <a class="header-anchor" href="#风险管理器" aria-label="Permalink to &quot;风险管理器&quot;">​</a></h2><p>该<code>RiskManager</code>通过多个验证层实施全面的交易前风险控制：</p><h3 id="风险控制配置" tabindex="-1">风险控制配置 <a class="header-anchor" href="#风险控制配置" aria-label="Permalink to &quot;风险控制配置&quot;">​</a></h3><table tabindex="0"><thead><tr><th>风险检查</th><th>配置键</th><th>目的</th></tr></thead><tbody><tr><td>头寸规模</td><td><code>max_position_size</code></td><td>最大位置值</td></tr><tr><td>每日损失</td><td><code>max_daily_loss</code></td><td>每日亏损限额</td></tr><tr><td>订单大小</td><td><code>max_order_size</code></td><td>最大订购数量</td></tr><tr><td>订单频率</td><td><code>order_frequency_limit</code></td><td>每分钟订单限制</td></tr><tr><td>价格验证</td><td><code>price_deviation_threshold</code></td><td>价格偏离市场</td></tr><tr><td>交易时间</td><td><code>trading_hours_check</code></td><td>基于时间的验证</td></tr></tbody></table><h3 id="增强价格验证" tabindex="-1">增强价格验证 <a class="header-anchor" href="#增强价格验证" aria-label="Permalink to &quot;增强价格验证&quot;">​</a></h3><p>风险管理者实施双层价格验证：</p><ol><li><strong>绝对价格限制</strong>：按工具类型划分的硬性限制</li><li><strong>相对价格偏差</strong>：与市场价格的百分比偏差</li></ol><h3 id="风险监控" tabindex="-1">风险监控 <a class="header-anchor" href="#风险监控" aria-label="Permalink to &quot;风险监控&quot;">​</a></h3><p>该系统包括实时风险监控和定期检查：</p><ul><li><strong>错误率监控</strong>：跟踪策略错误频率</li><li><strong>市场状况检查</strong>：验证交易时间和市场状况</li><li><strong>持仓集中度</strong>：监控投资组合集中度风险</li></ul><h2 id="订单管理器" tabindex="-1">订单管理器 <a class="header-anchor" href="#订单管理器" aria-label="Permalink to &quot;订单管理器&quot;">​</a></h2><p>该类<code>OrderManager</code>处理从下单到执行的完整订单生命周期、维护订单状态并与交易网关协调。</p><h3 id="订单数据管理" tabindex="-1">订单数据管理 <a class="header-anchor" href="#订单数据管理" aria-label="Permalink to &quot;订单数据管理&quot;">​</a></h3><p>订单管理器维护全面的订单跟踪：</p><table tabindex="0"><thead><tr><th>数据结构</th><th>目的</th><th>关键字段</th></tr></thead><tbody><tr><td><code>OrderInfo</code></td><td>订单元数据</td><td><code>order_data</code>，<code>strategy_id</code>，<code>create_time</code></td></tr><tr><td><code>orders</code></td><td>活动订单缓存</td><td><code>Dict[str, OrderInfo]</code></td></tr><tr><td><code>strategy_orders</code></td><td>策略顺序映射</td><td><code>Dict[str, set]</code></td></tr><tr><td><code>system_to_ctp_orderid</code></td><td>ID映射</td><td>系统 ID → CTP ID</td></tr></tbody></table><h3 id="订单-id-映射" tabindex="-1">订单 ID 映射 <a class="header-anchor" href="#订单-id-映射" aria-label="Permalink to &quot;订单 ID 映射&quot;">​</a></h3><p>系统维护内部订单ID和网关订单ID之间的双向映射：</p><ul><li><code>system_to_ctp_orderid</code>：将内部 UUID 映射到 CTP 订单 ID</li><li><code>ctp_to_system_orderid</code>：将 CTP 订单 ID 映射回内部 UUID</li></ul><p>这使得跨系统边界的正确订单跟踪成为可能。</p><h2 id="账户管理" tabindex="-1">账户管理 <a class="header-anchor" href="#账户管理" aria-label="Permalink to &quot;账户管理&quot;">​</a></h2><p>该<code>AccountManager</code>类别通过交易网关定期同步来跟踪账户余额、头寸和策略级损益。</p><h3 id="定期同步" tabindex="-1">定期同步 <a class="header-anchor" href="#定期同步" aria-label="Permalink to &quot;定期同步&quot;">​</a></h3><p>账户管理器实现自动同步：</p><ul><li><strong>查询间隔</strong>：30秒定期更新</li><li><strong>事件驱动更新</strong>：实时交易处理</li><li><strong>网关集成</strong>：账户和头寸查询</li></ul><h2 id="集成架构" tabindex="-1">集成架构 <a class="header-anchor" href="#集成架构" aria-label="Permalink to &quot;集成架构&quot;">​</a></h2><p>交易引擎通过事件驱动接口与更广泛的系统集成：</p><h3 id="关键事件类型" tabindex="-1">关键事件类型 <a class="header-anchor" href="#关键事件类型" aria-label="Permalink to &quot;关键事件类型&quot;">​</a></h3><table tabindex="0"><thead><tr><th>事件类型</th><th>来源</th><th>目标</th><th>目的</th></tr></thead><tbody><tr><td><code>STRATEGY_SIGNAL</code></td><td>战略</td><td>订单管理器</td><td>订单下达请求</td></tr><tr><td><code>RISK_APPROVED</code></td><td>风险管理器</td><td>订单管理器</td><td>风险验证结果</td></tr><tr><td><code>GATEWAY_SEND_ORDER</code></td><td>订单管理器</td><td>网关</td><td>订单执行</td></tr><tr><td><code>ORDER_FILLED</code></td><td>网关</td><td>客户经理</td><td>贸易更新</td></tr><tr><td><code>ACCOUNT_UPDATED</code></td><td>网关</td><td>客户经理</td><td>帐户同步</td></tr></tbody></table><!--[--><!----><div class="bg-$vp-custom-block-details-bg mt-6 vp-nolebase-git-changelog vp-nolebase-git-changelog-history vp-nolebase-git-changelog-history-list vp-nolebase-git-changelog-history-container" rounded-lg p-4 data-v-9cc63e9c><label cursor-pointer data-v-9cc63e9c><div class="vp-nolebase-git-changelog-title flex select-none items-center justify-between" transition="color ease-in-out" text="&lt;sm:xs" duration-200 data-v-9cc63e9c><span class="vp-nolebase-git-changelog-last-edited-title inline-flex items-center gap-3" data-v-9cc63e9c><div class="i-octicon:history-16" data-v-9cc63e9c></div><span data-v-9cc63e9c>最后编辑于 12 天前</span></span><div class="i-octicon:sort-desc-16" ml-auto mr-4 cursor-pointer data-v-9cc63e9c></div><span class="vp-nolebase-git-changelog-view-full-history-title inline-flex cursor-pointer items-center gap-3" data-v-9cc63e9c><span class="&lt;sm:hidden" data-v-9cc63e9c>查看完整历史</span><svg class="rotate-0 i-octicon:chevron-down-16" transition="transform ease-in-out" duration-200 data-v-9cc63e9c></svg></span></div></label><div style="display:none;" class="grid grid-cols-[30px_auto] mt-3 gap-1.5 children:my-auto -ml-1.5" text="&lt;sm:xs" data-v-9cc63e9c><!--[--><!--[--><!--[--><div class="i-octicon:git-commit-16 m-auto rotate-90 transform op-30" data-v-0e4a2b5f></div><div flex gap-1 align-baseline data-v-0e4a2b5f><a href="https://github.com/Homalos/HomalosDocs/commit/8a5355568ddf8b362af3d95b3507729a9d6aeb0d" target="_blank" class="no-icon" data-v-0e4a2b5f><code class="text-xs text-$vp-c-brand-1 hover:text-$vp-c-brand-1" transition="color ease-in-out" duration-200 data-v-0e4a2b5f>8a53555</code></a><span data-v-0e4a2b5f>-</span><span data-v-0e4a2b5f><span class="text-sm &lt;sm:text-xs" data-v-0e4a2b5f>修正文档中的标点错误，统一列表项的分隔符</span><span class="my-1 ml-3 gap-1" data-v-0e4a2b5f><!--[--><!--[--><img src="https://gravatar.com/avatar/b8d5677fa18909432d3b381a59fa6cbe31323f9c976d2c30c3d3c57032d01194?d=retro" alt="The avatar of contributor named as Donny" class="vp-nolebase-git-changelog-commit-avatar inline-block h-6 w-6 rounded-full v-middle" data-v-0e4a2b5f><!--]--><!--]--></span><!----></span></div><!--]--><!--]--><!--[--><!--[--><div class="i-octicon:git-commit-16 m-auto rotate-90 transform op-30" data-v-0e4a2b5f></div><div flex gap-1 align-baseline data-v-0e4a2b5f><a href="https://github.com/Homalos/HomalosDocs/commit/a05e3b87f1abfd4fab588641cd928118c960b271" target="_blank" class="no-icon" data-v-0e4a2b5f><code class="text-xs text-$vp-c-brand-1 hover:text-$vp-c-brand-1" transition="color ease-in-out" duration-200 data-v-0e4a2b5f>a05e3b8</code></a><span data-v-0e4a2b5f>-</span><span data-v-0e4a2b5f><span class="text-sm &lt;sm:text-xs" data-v-0e4a2b5f>Update core</span><span class="my-1 ml-3 gap-1" data-v-0e4a2b5f><!--[--><!--[--><img src="https://gravatar.com/avatar/b8d5677fa18909432d3b381a59fa6cbe31323f9c976d2c30c3d3c57032d01194?d=retro" alt="The avatar of contributor named as Donny" class="vp-nolebase-git-changelog-commit-avatar inline-block h-6 w-6 rounded-full v-middle" data-v-0e4a2b5f><!--]--><!--]--></span><!----></span></div><!--]--><!--]--><!--[--><!--[--><div class="i-octicon:git-commit-16 m-auto rotate-90 transform op-30" data-v-0e4a2b5f></div><div flex gap-1 align-baseline data-v-0e4a2b5f><a href="https://github.com/Homalos/HomalosDocs/commit/2a5dd9517432ae44dc52c9fab0062096f12c886e" target="_blank" class="no-icon" data-v-0e4a2b5f><code class="text-xs text-$vp-c-brand-1 hover:text-$vp-c-brand-1" transition="color ease-in-out" duration-200 data-v-0e4a2b5f>2a5dd95</code></a><span data-v-0e4a2b5f>-</span><span data-v-0e4a2b5f><span class="text-sm &lt;sm:text-xs" data-v-0e4a2b5f>Update zh.tx</span><span class="my-1 ml-3 gap-1" data-v-0e4a2b5f><!--[--><!--[--><img src="https://gravatar.com/avatar/b8d5677fa18909432d3b381a59fa6cbe31323f9c976d2c30c3d3c57032d01194?d=retro" alt="The avatar of contributor named as Donny" class="vp-nolebase-git-changelog-commit-avatar inline-block h-6 w-6 rounded-full v-middle" data-v-0e4a2b5f><!--]--><!--]--></span><!----></span></div><!--]--><!--]--><!--]--></div></div><!--]--></div></div></main><footer class="VPDocFooter" data-v-39a288b8 data-v-e257564d><!--[--><!--]--><div class="edit-info" data-v-e257564d><div class="edit-link" data-v-e257564d><a class="VPLink link vp-external-link-icon no-icon edit-link-button" href="https://github.com/Homalos/HomalosDocs/edit/main/src/core/trading_engine.md" target="_blank" rel="noreferrer" data-v-e257564d><!--[--><span class="vpi-square-pen edit-link-icon" data-v-e257564d></span> 在 GitHub 上编辑此页面<!--]--></a></div><div class="last-updated" data-v-e257564d><p class="VPLastUpdated" data-v-e257564d data-v-e98dd255>最后更新于: <time datetime="2025-07-19T10:22:28.000Z" data-v-e98dd255></time></p></div></div><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-e257564d><span class="visually-hidden" id="doc-footer-aria-label" data-v-e257564d>Pager</span><div class="pager" data-v-e257564d><a class="VPLink link pager-link prev" href="/core/event_driven_system" data-v-e257564d><!--[--><span class="desc" data-v-e257564d>上一页</span><span class="title" data-v-e257564d>事件驱动系统</span><!--]--></a></div><div class="pager" data-v-e257564d><a class="VPLink link pager-link next" href="/core/objects_and_service_registry" data-v-e257564d><!--[--><span class="desc" data-v-e257564d>下一页</span><span class="title" data-v-e257564d>核心对象和服务注册表</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!----><!--]--></div></div>
    
    
  </body>
</html>